﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpLearn_Chapter4.StringLearn
{
    internal class StringLearn
    {
        static float f = 12345.78f;

        static string str1 = "12345.78";
        string str1Formatted = String.Format("{0:N0}",f);

        //日期-时间格式化
        static DateTime now = DateTime.Now;
        string formattedDate = String.Format("{0:yyyy-MM-dd HH:mm:ss}", now);

        static decimal price = 1234.56m;
        string formattedPrice = String.Format("{0:C}", price); // 输出: 

        //Console.WriteLine($"Hello, {formattedDate}! ");
        // 输出: "2023-10-05 14:30:00"

        //String.Substring的使用
        static string id = "140104200201100127";
        static string strYear = id.Substring(6, 4);

        static int y = DateTime.Now.Year;

        int age = y - int.Parse(strYear);
    }
}
